package com.erp.servlet;

import com.erp.bean.Evaluate;
import com.erp.bean.Order;
import com.erp.bean.Supplier;
import com.erp.service.EvaluateService;
import com.erp.service.OrderService;
import com.erp.service.SupplierService;
import com.erp.service.impl.EvaluateServiceImpl;
import com.erp.service.impl.OrderServiceImpl;
import com.erp.service.impl.SupplierServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author mtf
 * 评价列表控制器
 */
@WebServlet("/evaluatelist.action")
public class EvaluateListServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //创建业务逻辑对象
        EvaluateService evaluateService = new EvaluateServiceImpl();
        //将查询到的对象放入集合中
        List<Evaluate> list = evaluateService.findAll();

        System.out.println(list);
        //创建供应商逻辑对象
        SupplierService supplierService = new SupplierServiceImpl();
        List<Supplier> suppliers = supplierService.findAll();
        req.setAttribute("suppliers",suppliers);
        //放入作用域
        req.setAttribute("list",list);
        //转发到人员列表页面
        req.getRequestDispatcher("evaluatelist.jsp").forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
